 package com.example.zx.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private TextView textView;
    private Button btn;
    private ImageView img;
    int i=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textView = findViewById(R.id.text1);
        textView.setTextSize(30);
        textView.setText("lalala");

        btn = findViewById(R.id.button);
        img = findViewById(R.id.imgs);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch(i){
                    case 0:img.setBackgroundResource(R.drawable.dog2);
                        i++;
                        break;
                    case 1:img.setBackgroundResource(R.drawable.dog3);
                        i++;
                        break;
                    case 2:img.setBackgroundResource(R.drawable.dog4);
                        i++;
                        break;
                    case 3:img.setBackgroundResource(R.drawable.dog5);
                        i++;
                        break;
                    case 4:img.setBackgroundResource(R.drawable.dog1);
                        i++;
                        break;
                }
                if (i>=5){
                    i=0;
                }
            }
        });
    }
}
